﻿<%@ Page Language="C#" MasterPageFile="~/Game/Game.Master" AutoEventWireup="true"
    CodeBehind="Map.aspx.cs" Inherits="smallDeimos.Game.Map" Title="Small Deimos - Map" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
        DataKeyNames="SystemID" DataSourceID="ObjectDataSource1" 
        OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
        <Columns>
            <asp:BoundField DataField="SystemID" HeaderText="SystemID" InsertVisible="False"
                ReadOnly="True" SortExpression="SystemID" />
            <asp:BoundField DataField="SystemName" HeaderText="SystemName" SortExpression="SystemName" />
            <asp:BoundField DataField="X" HeaderText="X" SortExpression="X" />
            <asp:BoundField DataField="Y" HeaderText="Y" SortExpression="Y" />
            <asp:CommandField SelectText="View" ShowSelectButton="True" />
        </Columns>
    </asp:GridView>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
        SelectMethod="GetSystemsInRange" TypeName="SD.Database.DataAccess">
        <SelectParameters>
            <asp:CookieParameter CookieName="sd_id" Name="pId" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:smallDeimosConnectionString %>"
        
        SelectCommand="SELECT SystemID, SystemName, X, Y FROM Systems WHERE (SQRT(POWER(X - (SELECT X FROM Systems AS Systems_2 WHERE (SystemID = (SELECT OrginID FROM Players WHERE (PlayerId = @pId)))), 2) + POWER(Y - (SELECT Y FROM Systems AS Systems_1 WHERE (SystemID = (SELECT OrginID FROM Players AS Players_2 WHERE (PlayerId = @pId)))), 2)) &lt;= (SELECT Biology FROM Players AS Players_1 WHERE (PlayerId = @pId)) / 2) AND (SystemID &lt;= (SELECT LastOrginID FROM Configuration))">
        <SelectParameters>
            <asp:CookieParameter CookieName="sd_id" Name="pId" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
